<?php


namespace app\index\model;


use think\Db;
use think\Model;

class Hostpital extends Model
{
    protected $table = 'xt_yymc_print';

/*    public  function insertHostptial($dh,$mc){
        $this->execute("INSERT INTO xt_yymc_print ( dh, mc, title, ywy, ywzg, yydj, psfs, fsfs, printfs, loginname, password, PassWord2, issendromote, beizhu, dycs, sfjb, createdate ) VALUES ( $dh, $mc, 1, '', '', '4', '配送', '0', '1', @dh, @dh, '1', '0', '2', '1', '3', '2019-06-16 06:16:06.006');" );
    }*/

    //增加签章
    public  function InsertSignature($yib){
        $time = date('Y-m-d h:i:s', time());
        $data = ['HosCode' =>$yib,'TitleType'=>'1','IsHaveFooter' =>'0',
            'IsMergeOnePerson'=>'0','CreateTime' =>$time,'UseSignature'=>'1'];
        $res = Db::table('Report.HospitalExtendPersonalise')->insert($data);
        if($res){
            return true;
        }
            return false;
    }

    //删除签章
    public  function DelSignature($yib){
        $res = $this->where('HosCode',$yib)->delete();
        if($res){
            return true;
        }
        return false;
    }

    //更新签章--修改更新
    public  function UplSignatures($yib, $UseSignature){

        $res = Db::table('Report.HospitalExtendPersonalise')->where('HosCode',$yib)->update(['UseSignature'=> $UseSignature]);
        //这儿会存在没有的情况 就是没有记录 那么就去新增
        if(!$res){
            $this->InsertSignature($yib);
        }
        return $res;
    }




    //删除签章
    public  function UplSignature($yib){
        $res = Db::table('Report.HospitalExtendPersonalise')->where('HosCode',$yib)->delete();
        if($res){
            return true;
        }
        return false;
    }

    //根据代号查询签章
    public  function GetSignatureByYid($yib){
        $res = $this->where('HosCode',$yib)->find();
        if($res){
            return true;
        }
        return false;
    }


    //根据代号查询项目信息
    public  function GetHostpitalByDh($dh){
        $data = [
            'dh' => $dh,
        ];
        return $this->where($data)->find();
    }

    //根据代号删除信息

    public function DelHospitalByDh($dh){
        $data = [
            'dh' => $dh,
        ];
        return $this->where($data)->delete();
    }
}